import { defaultPageSize } from "@/components/pagination/save";
export const Mixins = {
    data() {
        return {
            dataSource: [], // 数据源
            queryParam: {}, // 通用查询
            queryGutter: {
                // 查询条件响应式
                xs: 0,
                sm: 10,
                md: 0,
                lg: 0,
                xl: 20,
                xxl: 20,
            },
            querySpan: {
                // 查询条件响应式
                xs: 24,
                sm: 12,
                md: 12,
                lg: 8,
                xl: 6,
                xxl: 6,
            },
            ipagination: {
                // 分页参数
                current: 1,
                pageSize: defaultPageSize,
                total: 0,
                showQuickJumper: true,
                showSizeChanger: true,
            },
            tableLoading: false, // 表格是否在loading
            formVisible: true, // 查询条件是否可见
            labelCol: { span: 6 }, // label占位尺寸
            wrapperCol: { span: 18 }, // 输入框占位尺寸
        };
    },
    created() {

    },
    //生命周期 - 挂载完成（可以访问DOM元素）
    mounted() { this.getDataList(); },
    methods: {
        /**
         * 页数改变时
         * @param {} current
         * @param {*} size
         */
        paginationShowSizeChange(current, size) {
            this.ipagination.current = current;
            this.ipagination.pageSize = size;
            this.getDataList();
        },
        /**
         * 分页改变时
         * @param {*} page
         * @param {*} pageSize
         */
        paginationChange(page, pageSize) {
            this.ipagination.current = page;
            this.ipagination.pageSize = pageSize;
            this.getDataList();
        },
        /**
         * 获得查询参数
         * @returns
         */
        getQueryParams(isResetPage) {
            if (isResetPage) {
                this.resetPage()
            }
            let param = Object.assign({}, this.queryParam);
            param.pageNo = this.ipagination.current;
            param.pageSize = this.ipagination.pageSize;
            return param;
        },
        /**
         * 重置查询参数
         */
        reset() {
            Object.keys(this.queryParam).forEach((key) => {
                this.queryParam[key] = undefined;
            });
            this.resetPage()
            this.getDataList();
        },
        /**
         * 重置页码
         */
        resetPage() {
            this.ipagination.current = 1
            this.ipagination.pageSize = defaultPageSize
        },
    },
};
